<%-- 
    Document   : doctor
    Created on : Dec 20, 2011, 10:44:57 AM
    Author     : administrator
--%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<!-- RichFaces tag library declaration -->
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>

<%@page errorPage="/pages/error.jsp" contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<f:view locale="#{languagesBean.locale}">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title><h:outputText value="#{lang.doctorTitle}"/></title>
        </head>
        <body>
            <jsp:include page="/pages/header.jsp"/>
                
            <rich:tabPanel id="tabContainer" style="margin-left:auto; margin-right:auto;" width="80%" headerAlignment="right" selectedTab="stats">
                    
                    
                    <%-- DOCTOR'S PATIENT TAB --%>
                    <rich:tab id="patient" label="#{lang.doctorTabList}" action="#{patientList.allMyPatients()}">
                        <f:setPropertyActionListener target="#{patientList.docId}" value="#{user.id}"/>
                        
                        <a4j:form>
                            <rich:dataTable id="patients" value="#{patientList.patientList}" var="singlepatient" rows="20" align="center" width="100%">
                                
                                <f:facet name="header">
                                    <h:outputText value="#{lang.DoctorPatHeader}" />
                                </f:facet>
                                
                                <rich:column sortBy="#{singlepatient.id}">
                                    <f:facet name="header">
                                        <h:outputText value="#{lang.DoctorPatId}" />
                                    </f:facet>
                                    
                                    <%-- Link al Profilo del Paziente --%>
                                    
                                    <a4j:commandLink value="#{singlepatient.id}" action="#{patient.retrievePatient()}">
                                        <f:setPropertyActionListener target="#{patient.id}" value="#{singlepatient.id}"/>
                                        <f:setPropertyActionListener target="#{patient.refDoctorId}" value="#{user.id}"/>
                                        <f:setPropertyActionListener target="#{patient.callerId}" value="#{user.id}"/>
                                    </a4j:commandLink>
                                    
                                </rich:column>
                                
                                <rich:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{lang.DoctorPatPhoto}"/>
                                    </f:facet>
                                    <h:graphicImage value="#{singlepatient.picture}" width="50px" height="50px" />
                                </rich:column>
                                
                                <rich:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{lang.DoctorPatName}"/>
                                    </f:facet>
                                    <h:outputText value="#{singlepatient.name}"/>
                                </rich:column>
                                
                                <rich:column sortBy="#{singlepatient.surname}">
                                    <f:facet name="header">
                                        <h:outputText value="#{lang.DoctorPatSurname}"/>
                                    </f:facet>
                                    <h:outputText value="#{singlepatient.surname}"/>
                                </rich:column>
                                
                                <rich:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{lang.DoctorPatBirthdate}"/>
                                    </f:facet>
                                    <h:outputText value="#{singlepatient.birthdate}"/>
                                </rich:column>                            
                                
                                <rich:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{lang.DoctorPatParent}"/>
                                    </f:facet>
                                    <h:outputText value="#{singlepatient.parentId}"/>
                                </rich:column>
                                
                                
                                <f:facet name="footer">
                                    <rich:datascroller id="scroller" ></rich:datascroller>
                                </f:facet>
                                
                            </rich:dataTable>
                            
                        </a4j:form>
                        
                    </rich:tab>
                    
                    
                    
                    <%-- VISIT TAB --%>
                    <rich:tab  id="visit" label="#{lang.doctorTabVisit}" action="#{visitList.myScheduledVisits()}">
                        <f:setPropertyActionListener target="#{visitList.callingDoctorId}" value="#{user.id}"/>
                        
                        <a4j:form>
                            <rich:dataTable id="visitTable" value="#{visitList.visitList}" var="singlevisit" rows="20" width="100%">
                                
                                <f:facet name="header">
                                    <h:outputText value="#{lang.DoctorVisHeader}" />
                                </f:facet>
                                
                                
                                <rich:column sortBy="#{singlevisit.visit_id}">
                                    <f:facet name="header">
                                        <h:outputText value="#{lang.DoctorVisId}"/>
                                    </f:facet>
                                    <h:outputText value="#{singlevisit.visit_id}"/>
                                </rich:column>
                                
                                <rich:column sortBy="#{singlevisit.date}">
                                    <f:facet name="header">
                                        <h:outputText value="#{lang.DoctorVisDate}"/>
                                    </f:facet>
                                    <h:outputText value="#{singlevisit.date}"/>
                                </rich:column>
                                
                                <rich:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{lang.DoctorVisPatName}"/>
                                    </f:facet>
                                    <h:outputText value="#{singlevisit.patient_name}"/>
                                </rich:column>
                                
                                <rich:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{lang.DoctorVisMedName}"/>
                                    </f:facet>
                                    <h:outputText value="#{singlevisit.doctor_name}"/>
                                </rich:column>
                                
                                <rich:column sortBy="#{singlevisit.reminder}">
                                    <f:facet name="header">
                                        <h:outputText value="#{lang.DoctorVisReminds}"/>
                                    </f:facet>
                                    
                                    <h:graphicImage value="#{singlevisit.negligentImg()}" width="20" height="20" style="text-align:left;"/>
                                    
                                    <h:outputText value="#{singlevisit.reminder}" style="text-align:center;"/>
                                    
                                </rich:column>
                                
                                
                                <rich:column >
                                    <f:facet name="header">
                                        <h:outputText value="#{lang.DoctorVisReport}"/>
                                    </f:facet>
                                    
                                    <h:inputTextarea id="reportField" label="#{lang.DoctorVisReport}" value="#{singlevisit.report}" />
                                    
                                    <h:outputText value="#{lang.DoctorVisVoidReport}" rendered="#{singlevisit.voidReport}" style="color:red;"/>
                                    
                                </rich:column>
                                
                                <rich:column>
                                    <f:facet name="header">
                                        <h:outputText value="#{lang.DoctorVisAddVisit}"/>
                                    </f:facet>
                                    
                                    <a4j:commandButton value="#{lang.DoctorVisAddVisit}" action="#{visitList.examineFromList()}" reRender="visitTable">
                                        <f:setPropertyActionListener target="#{visitList.selected}" value="#{singlevisit.index}"/>
                                    </a4j:commandButton>
                                    
                                </rich:column>
                                
                                
                                <f:facet name="footer">
                                    <rich:datascroller id="scroller" ></rich:datascroller>
                                </f:facet>
                                
                            </rich:dataTable>                                
                        </a4j:form>
                        
                    </rich:tab>
                    
                    <%-- STATISTICS TAB --%>
                    <rich:tab id="stats" label="#{lang.doctorTabStat}">
                        <rich:panel header="#{lang.DoctorStatTitle}" style="width:100% text-align:center">
                            <rich:panel style="width:50%text-align:left">
                                <p>
                                    <h:outputText value="#{lang.DoctorStatPat} " />
                                    <h:outputText value="#{user.numberOfPatient()}" />
                                </p>
                                <p>
                                    <h:outputText value="#{lang.DoctorStatVis} " />
                                    <h:outputText value="#{user.numberOfVisits()}" />
                                </p>
                                <p>
                                    <h:outputText value="#{lang.DoctorStatSched} " />
                                    <h:outputText value="#{user.numberOfScheduled()}" />
                                </p>
                                <p>                            
                                    <h:outputText value="#{lang.DoctorStatRep} " />
                                    <h:outputText value="#{user.numberOfCompleted()}" />                               
                                </p>
                            </rich:panel> 
                            
                        </rich:panel>
                        
                    </rich:tab>
                    
                    
                    
                    <%-- REGISTER PATIENT TAB --%>
                    <rich:tab id="RegisterTab" label="#{lang.doctorRegHeader}" action="#{patient.blankPatient()}">
                        <f:setPropertyActionListener target="#{patient.refDoctorId}" value="#{user.id}"/>
                        
                        <a4j:form>
                            <rich:panel id="registerPanel" header="#{lang.doctorRegHeader}"  style="text-align:justify; height:100%; width:100%;">                       
                                <p>
                                    <h:outputText value="#{lang.doctorRegName} " />                            
                                    <h:inputText value="#{patient.name}"/>
                                    
                                    <h:outputText value="#{lang.doctorRegSurname} " />
                                    <h:inputText value="#{patient.surname}"/>
                                </p>
                                <p>
                                    <h:selectOneRadio id="gender" label="#{lang.doctorRegGender}" value="#{patient.gender}">
                                        <f:selectItem id="M" itemLabel="M" itemValue="M" />
                                        <f:selectItem id="F" itemLabel="F" itemValue="F" />
                                    </h:selectOneRadio>
                                </p>
                                
                                <h:outputText value="#{lang.doctorRegBirthDate} " />
                                <rich:calendar id="date" value="#{patient.calendarBirthdate}"/>
                                <br>
                                
                                <h:outputText value="#{lang.doctorRegBirthPlace} " />
                                <h:inputText value="#{patient.birthplace}"/>
                                
                                <h:outputText value="#{lang.doctorRegAddress} " />
                                <h:inputText value="#{patient.address}"/>
                                <br>
                                
                                <h:outputText value="#{lang.doctorRegCAP} " />
                                <h:inputText value="#{patient.cap}"/>
                                <br>
                                
                                <h:outputText value="#{lang.doctorRegEmail} " />
                                <h:inputText value="#{patient.email}" />
                                <br>
                                
                                <h:outputText value="#{lang.doctorRegParentUsername} " />
                                <h:inputText value="#{patient.parentId}"/>
                                <br>
                                
                                <h:outputText value="#{lang.doctorRegCell} " />
                                <h:inputText value="#{patient.phone}"/>
                                <br>
                                
                                <h:outputText value="#{lang.doctorRegChiefTain} " />
                                <h:inputText value="#{patient.chiefTainId}"/>
                                <br>
                                
                                <h:outputText value="#{lang.doctorRegPictures} " />
                                <%-- Upload Pictures --%>
                                <rich:simpleTogglePanel opened="false" value="Upload #{lang.doctorRegPictures}" width="50%">
                                    <rich:fileUpload                    
                                        fileUploadListener="#{patient.uploadListener}"
                                        maxFilesQuantity="1"
                                        immediateUpload="true"
                                        acceptedTypes="jpg, gif, png, bmp"
                                        />
                                </rich:simpleTogglePanel>
                                <br>
                                
                                <%-- Messages --%>
                                <h:outputText value="#{lang.doctorRegSuccess}" rendered="#{patient.registrationCompleted}" style="color:green; font-size:14px;"/><BR>
                                <h:outputText value="#{lang.doctorRegFail}" rendered="#{patient.registrationFailed}" style="color:red; font-size:14px;"/><BR>
                                
                                <a4j:commandButton value="#{lang.doctorRegRegisterAction}" action="#{patient.registerPatient()}" reRender="registerPanel">
                                    <f:setPropertyActionListener target="#{patient.refDoctorId}" value="#{user.id}"/>
                                </a4j:commandButton>
                            </rich:panel>
                        </a4j:form>
                    </rich:tab>
                    
                </rich:tabPanel>
        </body>
    </html>
</f:view>